package com.hmy.contract.controller;

import com.hmy.ccp.common.response.BasePageResponse;
import com.hmy.ccp.common.result.JsonResult;
import com.hmy.ccp.error.annotations.HmyGateWayController;
import com.hmy.contract.bo.request.contract.*;
import com.hmy.contract.bo.response.contract.*;
import com.hmy.contract.service.contract.ISupplyContractApprovalService;
import com.hmy.contract.service.contract.ISupplyContractService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @description 增补合同管理
 * @author seven.qi
 * @date 2023/12/19 19:32
 * @version 1.0
 */

@RestController
@RequestMapping("/api/supplyContract")
@Api(tags = "增补合同管理")
@Validated
@HmyGateWayController
@Slf4j
public class SupplyContractController {

    @Resource
    private ISupplyContractService supplyContractService;

    @Resource
    private ISupplyContractApprovalService supplyContractApprovalService;

    /**
     * 增补合同创建
     *
     * @param createSupplyContractRequest 合同创建入参
     * @return {@link JsonResult<CreateSupplyContractResponse>}
     */
    @PostMapping("createSupplyContract")
    public JsonResult<CreateSupplyContractResponse> createSupplyContract(@RequestBody CreateSupplyContractRequest createSupplyContractRequest){
        return JsonResult.success(supplyContractService.createSupplyContract(createSupplyContractRequest));
    }

    /**
     * 获取增补合同信息
     *
     * @param supplyContractInfoRequest 获取合同信息入参
     * @return {@link JsonResult<SupplyContractInfoResponse>}
     */
    @GetMapping("supplyContractInfo")
    public JsonResult<SupplyContractInfoResponse> getSupplyContractInfo(SupplyContractInfoRequest supplyContractInfoRequest){
        return JsonResult.success(supplyContractService.getSupplyContractInfo(supplyContractInfoRequest));
    }

    /**
     * 上传增补合同文件地址
     *
     * @param updateSupplyContractFileUrlRequest 更新增补合同文件地址入参
     * @return {@link JsonResult<UploadSupplyContractFileUrlResponse>}
     */
    @PostMapping("uploadSupplyContractFileUrl")
    public JsonResult<UploadSupplyContractFileUrlResponse> uploadSupplyContractFileUrl(@RequestBody UploadSupplyContractFileUrlRequest updateSupplyContractFileUrlRequest){
        return JsonResult.success(supplyContractService.uploadSupplyContractFileUrl(updateSupplyContractFileUrlRequest));
    }

    /**
     * 增补合同分页查询
     *
     * @param supplyContractPageRequest 分页查询入参
     * @return {@link JsonResult<BasePageResponse<SupplyContractPageResponse>>}
     */
    @GetMapping("page")
    public JsonResult<BasePageResponse<SupplyContractPageResponse>> page(SupplyContractPageRequest supplyContractPageRequest){
        return JsonResult.success(supplyContractService.page(supplyContractPageRequest));
    }

    /**
     * 变更增补合同签署方式
     * @param modifySupplyContractModelRequest 变更增补合同签署方式入参
     * @return {@link JsonResult<ModifySupplyContractModelResponse>}
     */
    @PostMapping("modifySupplyContractModel")
    public JsonResult<ModifySupplyContractModelResponse> modifySupplyContractSignModel(@RequestBody ModifySupplyContractModelRequest modifySupplyContractModelRequest){
        return JsonResult.success(supplyContractService.modifySupplyContractSignModel(modifySupplyContractModelRequest));
    }

    /**
     * 获取增补合同审批历史
     * @param supplyContractApprovalHistoryRequest 获取增补合同审批历史入参
     * @return {@link JsonResult<SupplyContractApprovalHistoryResponse>}
     */
    @GetMapping("supplyContractApprovalHistory")
    public JsonResult<SupplyContractApprovalHistoryResponse> getSupplyContractApprovalHistory(SupplyContractApprovalHistoryRequest supplyContractApprovalHistoryRequest){
        return JsonResult.success(supplyContractApprovalService.getSupplyContractApprovalHistory(supplyContractApprovalHistoryRequest));
    }

    /**
     * 风控部长审批增补合同
     * @param supplyContractApprovalRequest 风控部长审批增补合同入参
     * @return {@link JsonResult<RiskMinisterApprovalSupplyContractResponse>}
     */
    @PostMapping("riskMinisterApprovalSupplyContract")
    public JsonResult<RiskMinisterApprovalSupplyContractResponse> riskMinisterApprovalSupplyContract(@RequestBody RiskMinisterApprovalSupplyContractRequest supplyContractApprovalRequest){
        return JsonResult.success(supplyContractApprovalService.riskMinisterApprovalSupplyContract(supplyContractApprovalRequest));
    }

    /**
     * 区域经理审批增补合同
     * @param areaManagerApprovalSupplyContractRequest 区域经理审批增补合同入参
     * @return {@link AreaManagerApprovalSupplyContractResponse}
     */
    @PostMapping("areaManagerApprovalSupplyContract")
    public JsonResult<AreaManagerApprovalSupplyContractResponse> areaManagerApprovalContract(@RequestBody AreaManagerApprovalSupplyContractRequest areaManagerApprovalSupplyContractRequest){
        return JsonResult.success(supplyContractApprovalService.areaManagerApprovalContract(areaManagerApprovalSupplyContractRequest));
    }
}
